<?php

namespace App\Http\Requests\Logic\Genre;

use Illuminate\Validation\Rule;
use Illuminate\Foundation\Http\FormRequest;

class UpdateResource extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return isManager();
    }

	/**
	 * 定义表单验证规则
	 *
	 * Date: 21/04/2018
	 * @author George
	 * @return array
	 */
	public function rules()
	{
		return [
			'code' => [
				'required',
				Rule::unique('genres')->ignore($this->genre->id)
			],
			'name' => 'required',
			'start' => 'required',
			'end' => 'required',
		];
	}

	/**
	 * 定义表单验证错误消息
	 *
	 * Date: 21/04/2018
	 * @author George
	 * @return array
	 */
	public function messages()
	{
		return [
			'code.required' => '请输入排班类型编码',
			'name.required' => '请输入排班类型名称',
		];
	}
}
